<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        /* 页面背景 */
        body {
            background-color: black;
        }
        /* 承载整个火柴人 */
        .container {
            width: 300px;
            height: 300px;
            margin: 50px;
        }

        .person{
            position: absolute;    /*让下面的子级容器以此为参照*/
            left: 150px;
            top: 160px;
            animation: sprint 4s infinite ease-in;
        }
        /* 火柴人头部 */
        .head{
            position: absolute;
            width: 30px;
            height: 30px;
            border: 5px solid white;  /*边框属性*/
            border-radius: 50%;     /*边框形状，圆形*/
            top: -30px;
            left: -6px;
            animation: bob 2s infinite alternate;
        }
        /* 火柴人躯干 */
        .torso{
            width: 0;
            height: 60px;
            border-left: 5px solid white; /*用边框实现形状*/
            position: absolute;
            left: 0;
            top: 15px;
        }
        .person .part{
            position: absolute;
            left: 0;   /*以左侧为基准*/
            top: 75px;
        }

        /* 火柴人两条胳膊的共同属性部分 */
        .person .part.arm{
            width: 40px;
            height: 45px;
            border-left: 5px solid #fff;      /*用容器的左边框和下边框作为火柴人的胳膊*/
            border-bottom: 5px solid #fff;
            position: absolute;
            top: 15px;
            right: 300px;
            transform-origin: 0% 0% 0px;    /*指定变换的基点*/
            animation: pump 1s infinite ease-in-out;
        }
        /* 左胳膊 */
        .person .part.arm.one{
            transform:rotate3d(0,0,1,80deg);  /*左胳膊旋转80度*/
            
        }
        /* 右胳膊 */
        .person .part.arm.two{
            transform:rotate3d(0,0,1,-80deg);
            /* 右胳膊延时播放0.5秒，实现交错摆动效果 */
            animation-delay: 0.5s;
        }

        /* 火柴人腿部 */
        .person .part.leg{
            width: 60px;
            height: 60px;
            border-right: 5px solid #fff;
            border-top: 5px solid #fff;
            transform-origin: 0% 0% 0px;
            animation: run 1s infinite ease-in;
        }

        .person .part.leg.one{
            transform:rotate3d(0,0,1,100deg);
        }
        .person .part.leg.two{
            transform:rotate3d(0,0,1,10deg);
            animation-delay: 0.5s;
        }

        /* 头部动画 */
        @keyframes bob{
            0%{
                transform: rotate3d(0,0,1,5deg);
            }
            25%{
                transform: rotate3d(0,0,1,-30deg) skew(15deg,0deg);
            }
            50%{
                transform: rotate3d(0,0,1,5deg);
            }
            75%{
                transform: rotate3d(0,0,1,-30deg) skew(15deg,0deg);
            }
            100%{
                transform: rotate3d(0,0,1,20deg) skew(-15deg,0deg);
            }
        }

        /* 胳膊摆动 */
        @keyframes pump{
            0%{
                transform: rotate3d(0,0,1,80deg);
            }
            50%{
                transform: rotate3d(0,0,1,-70deg);
            }
            100%{
                transform: rotate3d(0,0,1,80deg);
            }
        }

        /* 腿部动画 */
        @keyframes run{
            0%{
                transform: rotate3d(0,0,1,-5deg);
            }
            50%{
                transform: rotate3d(0,0,1,150deg);
            }
            100%{
                transform: rotate3d(0,0,1,-5deg);
            }
        }

        /* 让人物跑起来 */
        @keyframes sprint{
            0%{
                /* translate为平移函数 */
                transform: translate(-200px,0px);
            }
            100%{
                transform: translate(1800px,0px);
            }
        }
    </style>
</head>

<body>

    <!-- 火柴人结构 -->
    <div class="container">
        <div class="person">
            <div class="head"></div>
            <div class=" part arm one"></div>
            <div class=" part arm two"></div>
            <div class="torso"></div>      <!--躯干-->
            <div class="part leg one"></div>
            <div class="part leg two"></div>
        </div>
    </div>

</body>

</html>